import { createRouter, createWebHistory } from 'vue-router';

const routes = [
    {
        path:"/",
        redirect:"/login"
    },
	{
		path:"/login",
		name:"login",
		component:()=>import("@/views/login/index.vue")
	},
    {
        path:"/index",
        name:"index",
        redirect:"/index/homepage",
        component:()=>import("@/views/home/index.vue"),
        children:[
            {
                path:"/index/homepage",
                name:"homepage",
                component:()=>import("@/views/home/homepage.vue"),
                meta:{
                    title:"首页",
                    icon:"iconfont icon-shouye"
                }
            },
            {
                path:"/index/user",
                name:"user",
                component:()=>import("@/views/user/index.vue"),
                meta:{
                    title:"个人信息",
                    icon:"iconfont icon-shouye"
                }
            },
            {
                path:"/index/books",
                name:"books",
                component:()=>import("@/views/books/index.vue"),
                meta:{
                    title:"图书管理",
                    icon:"iconfont icon-shouye"
                },
                children:[
                    {
                        path:"/index/books/list",
                        name:"booksList",
                        component:()=>import("@/views/books/list.vue"),
                        meta:{
                            title:"图书列表"
                        }
                    },
                    {
                        path:"/index/books/detail",
                        name:"booksDetail",
                        component:()=>import("@/views/books/detail.vue"),
                        meta:{
                            title:"图书详情"
                        }
                    }
                ]
            }
        ]
    }
];

const router = createRouter({
	history: createWebHistory(process.env.BASE_URL),
	routes
});

// 路由守卫
// router.beforeEach((to,from,next)=>{

// });

export default router
